<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<meta name="format-detection" content="telephone=no">
		<meta name="description" content="">
		<title></title>
		<link rel="stylesheet" href="../imgv2/css/default.min.css" />
		<link rel="stylesheet" href="../jsv2/bootstrap/css/bootstrap-ico.css" />
		<link rel="stylesheet" href="../imgv2/css/journey/css.css" />
		<style>
			body {
				overflow: hidden;
			}
			.friends-list {
				overflow-y: auto;
			}
			.itemarrow.arrow-noactive,
			.itemarrow.arrow-noactive li {
				display: none;
			}
			.itemarrow.arrow-active,
			.itemarrow.arrow-active li {
				display: '';
			}
		</style>
	</head>

	<body>

		<body class="whitebg">
			<!--wrap start-->
			<section id="wrap">
				<div id="headerview" style="height: 44px;">
					<div class="cm-header cm-header--no-right" id="ui-view-16">
						<span class="cm-header-icon fl js_back"><i class="icon-back"></i></span>
						<h1 class="cm-page-title js_title">更换领队</h1>
					</div>
				</div>
				<section class="citylist whitebg friends-list">
				</section>
				<section class="bottombtnarea">
					<ul class="listitem h60">
						<button id="btnOK" class="bigbtn button" onClick="this.className='button_d bigbtn'" onmouseout="this.className='bigbtn button'">确定</button>
					</ul>
				</section>
			</section>
		</body>
		<script src="../jsv2/jQuery/jquery-1.11.2.min.js"></script>
		<script src="../jsv2/lib/json3.min.js"></script>
		<script src="../jsv2/QueryStringParser.js"></script>
		<script src="../jsv2/jsonMsg.js"></script>
		<script src="../jsv2/lib/k-utils-fn.js"></script>
		<script src="../jsv2/journey/operateData.js"></script>
		<script>
			var parentwin = window.parent,
				openId, tripId;
			$(function() {
				openId = queryString.getParam("openid");
				tripId = queryString.getParam("tripid");
				$('.friends-list').css({
					'height': (K.getPageSize()[1] - 100) + 'px'
				});
				//说明：此处应该是本旅程中已经参加的好友中选择
				/*getFriendsListByAjax(openId, function(data) {
					if (data) {
						var profiles = data,
							innerContain = [];
						$.each(profiles, function(index) {
							if (index == 0) {
								$(".friends-list").html('');
							}
							var sex = "男";
							if (profiles[index].Sex == 'female') {
								sex = "女";
							}
							var imageURL = profiles[index].ImageURL;
							if (imageURL.substring(imageURL.length - 2) == "/0") {
								imageURL = imageURL.substring(0, imageURL.length - 2) + "/64";
							}
							var province = profiles[index].province == null ? "" : profiles[index].province;
							var city = profiles[index].city == null ? "" : profiles[index].city;
							innerContain.push('<a href="javascript:void(0);">');
							innerContain.push('		<img src="' + imageURL + '" width="100%" height="100%" class="tripuser" />');
							innerContain.push('		<ul class="listitem h120 bottomline">');
							innerContain.push('			<li class="itemcon lh120">' + profiles[index].NickName + '</li>');
							innerContain.push('			<li class="itemarrow lh120"><i class="iconfont blue">&#xe602;</i></li>');
							innerContain.push('		</ul>');
							innerContain.push('</a>');
						});
						$(".friends-list").html(innerContain.join(''));
					}
				});*/
				$(document).on('click', '.friends-list a', function(e) {
					var tar = $(e.target);
					tar = _getTarparanet(tar, {
						key: 'tagName',
						'value': 'A'
					});
					$('.friends-list .itemarrow').removeClass('arrow-active').addClass('arrow-noactive');
					$('.itemarrow', tar).removeClass('arrow-noactive').addClass('arrow-active');
				});
				$('#btnOK').on('click', function() {
					var tar = _getTarparanet($('.friends-list a .arrow-active'), {
						key: 'tagName',
						'value': 'A'
					});
					//console.log(tar.attr('OpenID'));
					parentwin && parentwin.changeTripLeader(tar.attr('OpenID'));
					$('.js_back').click();
				});
				bidgeToWeixin(openId, 'TripDetail', {
					"TripID": tripId
				}, function(data, status, xhr) {
					var data = data.portalResp.Data,
						innerContain = [];
					$.each(data.MemberStatus, function(index) {
						innerContain.push('<a href="javascript:void(0);" OpenID="' + data.MemberStatus[index].OpenID + '">');
						innerContain.push('		<img src="' + data.MemberStatus[index].ImageURL + '" width="100%" height="100%" class="tripuser" />');
						innerContain.push('		<ul class="listitem h120 bottomline">');
						innerContain.push('			<li class="itemcon lh120">' + data.MemberStatus[index].Nickname + '</li>');
						innerContain.push('			<li class="itemarrow lh120 ' + (data.TripLeader == data.MemberStatus[index].OpenID ? 'arrow-active' : 'arrow-noactive') + '"><i class="iconfont blue">&#xe602;</i></li>');
						innerContain.push('		</ul>');
						innerContain.push('</a>');
					});
					$(".friends-list").html(innerContain.join(''));
				});
			});
		</script>

</html>